﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml;

namespace WargameForDistribution
{
    public static class WarMatchs
    {
        public static int count_match;
        public static string maproot, scenarioroot, judge_tables_root;
        public static int ServerPort;
        public static string ServerIP;
        public static string System_path;
        //读取配置文件获得以下信息 //比赛的局数
        //初始化地图、态势信息,需要在GameEvolve中调用该类
        //读取服务器地址，端口
        // 创建一个XmlDocument对象
        public static void Init()
        {
            XmlDocument doc = new XmlDocument();
            string solutionPath = Directory.GetCurrentDirectory() + "\\..\\..\\..\\";
            System_path = solutionPath;
            //Console.WriteLine("当前解决方案的路径： " + solutionPath + "\\..\\..\\config.xml");
            string s = Path.Combine(solutionPath, @"WargameEngine\config.xml");
            doc.Load(Path.Combine(solutionPath, @"WargameEngine\config.xml"));
            XmlNode root = doc.DocumentElement;
            foreach (XmlNode node in root.ChildNodes)
            {
                if (node.Name == "ServerIP")
                    ServerIP = node.InnerText;
                if (node.Name == "ServerPort")
                    ServerPort = int.Parse(node.InnerText);
                if (node.Name == "maproot")
                    maproot = Path.Combine(solutionPath, node.InnerText);
                if (node.Name == "scenarioroot")
                    scenarioroot = Path.Combine(solutionPath, node.InnerText);
                if (node.Name == "judgetablesroot")
                    judge_tables_root = Path.Combine(solutionPath, node.InnerText);
                if (node.Name == "match_count")
                    count_match = int.Parse(node.InnerText);
            }
        }
    }
}